@file:JvmName("DimensionUtils")

package com.matuw.android.util.extensions

import android.content.res.Resources
import android.util.TypedValue
import com.matuw.androidSdk

val Float.dp
    get() = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this, displayMetrics) + 0.5F

val Int.dp get() = this.toFloat().dp

val Float.sp
    get() = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, this, displayMetrics)

val Int.sp get() = this.toFloat().sp

private val displayMetrics
    get() = (QinSdk.getApp()?.resources ?: Resources.getSystem()).displayMetrics

